package com.baomidou.mybatisplus.criterion;

/**
 * 查询条件接口的“简单”实现类，应用于二元操作符<br/>
 * 模仿自了hibernate的SimpleExpression，但做了简化
 * @author Timothy Ren
 */
public class SimpleExpression implements QueryCriterion {

	private static final long serialVersionUID = 1L;
	private final String propertyName;
	private final Object value;
	private final String op;

	protected SimpleExpression(String propertyName, Object value, String op) {
		this.propertyName = propertyName;
		this.value = value;
		this.op = op;
	}

	protected final String getOp() {
		return op;
	}

	public String getPropertyName() {
		return propertyName;
	}

	public Object getValue() {
		return value;
	}

	public String toSqlString() {
		return new StringBuffer().append(propertyName).append(getOp()).append("?").toString();
	}

	public Object[] getValueArr() {
		Object[] o = { value };
		return o;
	}

	public String toString() {
		return new StringBuffer().append(propertyName).append(getOp()).append(value).toString();
	}

}
